// $codepro.audit.disable unnecessaryImport
/**
 * Package domain
 */
package teamrocket.domain; // $codepro.audit.disable packagePrefixNamingConvention -->

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;

import teamrocket.db.DBWrapper;
import teamrocket.logging.TLogger;

/**
 * Represents a doctor in the office system
 * @author Stephen
 *
 * @version $Revision: 1.0 $
 */
public class Doctor extends User{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * Field accessLevel.
	 */
	private String accessLevel;
	
	/**
	 * Field patients.
	 */
	private Patient[] patients;
	
	/**
	 * Field appointments.
	 */
	private Appointment[] appointments; // $codepro.audit.disable com.instantiations.assist.eclipse.analysis.unassignedField
	
	/**
	 * Field doctorDefPerms.
	 * (value is "User.LOGIN + User.MODDRORDERS + User.MODPATIENTS + User.MODTR +
		User.VIEWAPPTS + User.VIEWREPORTS")
	 */
	private static final String DOCTORDEFPERMS = 
		User.LOGIN + User.MODDRORDERS + User.MODPATIENTS + User.MODTR +
		User.VIEWAPPTS + User.VIEWREPORTS;
	
	/**
	 * Constructs a doctor object in memory
	 * @param username
	 * @param password
	 * @param firstName
	 * @param lastName
	 */
	public Doctor(String username, String password, String firstName,
			String lastName) {
		super(username, password, firstName, lastName, "d", DOCTORDEFPERMS);
		TLogger.getInstance().getLogger().log(Level.INFO,
				"Creating new Doctor " + username);
	}
	
	/**
	 * Method getAccessLevel.
	 * @return String
	 */
	public String getAccessLevel() {
		return accessLevel;
	}
	
	/**
	 * Method setAccessLevel.
	 * @param accessLevel String
	 */
	public void setAccessLevel(String accessLevel) {
		this.accessLevel = accessLevel;
	}
	
	/**
	 * Method getPatients.
	 * @return Patient[]
	 */
	public Patient[] getPatients() {
		return patients;
	}
	
	/**
	 * Method setPatients.
	 * @param patients Patient[]
	 */
	public void setPatients(Patient[] patients) {
		this.patients = patients; // $codepro.audit.disable com.instantiations.assist.eclipse.arrayIsStoredWithoutCopying
	}
	
	/**
	 * Method getAppointments.
	 * @return Appointment[]
	 */
	public Appointment[] getAppointments() {
		return appointments;
	}
	
	/**
	 * Method setAppointments.
	 * @param appointments Appointment[]
	 */
	public void setAppointments(Appointment[] appointments) {
		this.appointments = appointments; // $codepro.audit.disable com.instantiations.assist.eclipse.arrayIsStoredWithoutCopying -->
	}
	/*public static List<User> lookupAllDoctors()
	{
		List<User> doctors = new ArrayList<User>();
		
		String sqlStatement = "SELECT * FROM users WHERE usertype = 'd'";


		try {
			ResultSet rs = DBWrapper.query(sqlStatement);

			while(rs.next()){
				
				User u = new User(
						rs.getString("username"),
						rs.getString("password"),
						rs.getString("firstname"),
						rs.getString("lastname"),
						rs.getString("usertype"),
						rs.getString("accessstring"));
				u.setUID(rs.getInt("id"));
				doctors.add(u);
				
				
				
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return doctors;

	
	}
	public static User lookupDoctor(int doctorID)
	{
		
		
		String sqlStatement = "SELECT * FROM users WHERE id = ?";


		try {
			ResultSet rs = DBWrapper.query(sqlStatement,doctorID);

			while(rs.next()){
				
				User u = new User(
						rs.getString("username"),
						rs.getString("password"),
						rs.getString("firstname"),
						rs.getString("lastname"),
						rs.getString("usertype"),
						rs.getString("accessstring"));
				u.setUID(rs.getInt("id"));
				return u;
				
				
				
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return null;

	
	}*/

}
